<?php
/**
 * 周舟 hzboye010@163.com
 * addby sublime snippets
 * user member group log api
 */

namespace app\system\api;

use app\system\model\UserMember;
use app\common\api\BaseApi;

class UserMemberApi extends BaseApi{

	const ADD             = "system/UserMemberApi/add";
	const SAVE            = "system/UserMemberApi/save";
	const SAVE_BY_ID      = "system/UserMemberApi/saveByID";
	const DELETE          = "system/UserMemberApi/delete";
	const QUERY           = "system/UserMemberApi/query";
	const GET_INFO        = "system/UserMemberApi/getInfo";
	const GET_WITH_GROUP  = "system/UserMemberApi/getWithGroup";
	const QUERY_NO_PAGING = "system/UserMemberApi/queryNoPaging";

	//初始化
	protected function _init(){
		$this->model = new UserMember();
	}

	public function getWithGroup($map,$order=false,$field=false){
     $result = $this->model->alias('m')
     ->join(' left join itboye_user_group g on m.group_id = g.id')
     ->where($map)->order($order)-> field($field) -> find();
    if (false === $result) {
        return $this -> apiReturnErr($this -> model -> getDbError());
    } else {
        if(empty($result)) $result = [];
        return $this -> apiReturnSuc($result);
    }
	}
}